package lib

import (
	"fmt"
	"github.com/PuerkitoBio/goquery"
)

type Pageitem struct {
	Filename string
	Img      string
	FitUrl   string
}
type Job struct {
	Url string
	Nub int
}

func GetURl(url string) (pages []*Pageitem) {
	d, err := goquery.NewDocumentGBK(url)
	if err != nil {
		fmt.Println("Search webpage err:%s", err)
		return
	}
	pages = []*Pageitem{}
	d.Find("#container div").Each(func(i int, item *goquery.Selection) {
		//fmt.Println(i)
		page := Pageitem{}

		page.Filename, _ = item.Find("div a").Attr("alt")
		page.Img, _ = item.Find("div").Eq(1).Find("a img").Attr("src2")
		page.FitUrl, _ = item.Find("div a").Attr("href")
		page.FitUrl = "http://sc.chinaz.com" + page.FitUrl
		pages = append(pages, &page)
	})
	return
}
